package com.example.Controller;

import com.example.entity.Album;
import com.example.entity.Myalbum;
import com.example.service.AlbumService;
import com.example.utils.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * The type Album controller.
 */
@CrossOrigin //跨域
@RestController
@RequestMapping(value = "/album")
public class AlbumController {
    @Autowired
    private AlbumService albumService;

    /**
     * Add album result data.
     *
     * @param album the album
     * @return the result data
     */
    @PostMapping("/addAlbum")
    public ResultData addAlbum(@RequestBody Album album) {
        return albumService.addAlbum(album);
    }

    /**
     * Gets album.
     *
     * @param album the album
     * @return the album
     */
    @PostMapping("/getAlbum")
    public ResultData getAlbum(@RequestBody Album album) {
        return albumService.getAlbum(album);
    }

    /**
     * Add myalbum result data.
     *
     * @param file    the file
     * @param myalbum the myalbum
     * @return the result data
     */
    @PostMapping("/addMyalbum")
    public ResultData addMyalbum(@RequestParam("file") MultipartFile file, Myalbum myalbum) {
        return albumService.addMyalbum(file, myalbum);
    }

    /**
     * Gets myalbum.
     *
     * @param myalbum the myalbum
     * @return the myalbum
     */
    @PostMapping("/getMyalbum")
    public ResultData getMyalbum(@RequestBody Myalbum myalbum) {
        return albumService.getmyAlbum(myalbum);
    }

    /**
     * Delete album result data.
     *
     * @param album the album
     * @return the result data
     */
    @PostMapping("/deleteByid")
    public ResultData deleteAlbum(@RequestBody Album album) {
        return albumService.DeleteAlbum(album);
    }

    /**
     * Del my album byid result data.
     *
     * @param myalbum the myalbum
     * @return the result data
     */
    @PostMapping("/delMyAlbumByid")
    public ResultData delMyAlbumById(@RequestBody Myalbum myalbum) {
        return albumService.DeleteMyAlbum(myalbum);
    }

}
